package com.hxzy.feign;

import com.hxzy.common.resp.R;
import com.hxzy.feign.fallback.OrderServiceFeignFallback;
import com.hxzy.feign.fallbackfactory.OrderServiceFeignFallbackFactory;
import com.hxzy.order.req.OrderReq;
import com.hxzy.order.req.OrderSearchReq;
import com.hxzy.order.resp.OrderResp;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.cloud.openfeign.SpringQueryMap;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

/**
 * @Author wy
 * @Description  订单服务的feign定义
 * @Date 2023/10/12 16:15
 * @Version 1.0
 */
@FeignClient(value = "order-server", fallbackFactory = OrderServiceFeignFallbackFactory.class)
public interface OrderServiceFeign {

    @GetMapping(value = "/order/bean/findById/{id}")
    R<OrderResp> orderFindById(@PathVariable(value = "id") Integer id);

    @GetMapping(value = "/order/bean/data")
    R<Map<String,Object>>   orderData(@SpringQueryMap OrderSearchReq req);

    @GetMapping(value = "/order/bean/data")
    R<Map<String,Object>>   orderDataParam(@RequestParam(value = "page") Integer page,
                                           @RequestParam(value = "size") Integer size,
                                           @RequestParam(value = "userId") Integer userId,
                                           @RequestParam(value = "name") String name);


    /**
     * 远程调用订单创建的API
     * @param req
     * @return
     */
    @PostMapping(value = "/order/bean/create")
    R<String> createOrder(@RequestBody OrderReq req);
}
